<!--@foreach($oDocument->getExtraVars() as $key => $val)-->
    <!--@if($val->name=="위도")-->
	    {@
			$latitude = $val->getValueHTML();
	    }
    <!--@elseif($val->name=="경도")-->
	    {@
			$longitude = $val->getValueHTML();
	    }
    <!--@end-->
<!--@end-->

<!--%import("css/default.css")-->

<script type="text/ecmascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="./js/jquery.printElement.js"></script>

<script type="text/javascript">
// <![CDATA[ 
(function($){
    $(function(){
		$(document).ready(function() {
			var latlng = new google.maps.LatLng({$latitude}, {$longitude});
			var myOptions = {
				zoom: 16,
				center: latlng,
				mapTypeId: google.maps.MapTypeId.ROADMAP,
				scrollwheel: false
			};
			var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
						
			var marker = new google.maps.Marker({
		      position: latlng, 
		      map: map, 
		      title:"{$oDocument->getTitle()}"
		    });
		});
		//인쇄팝업
    });
})(jQuery);
// ]]>
</script>


<div class="board_read">
	<!-- READ HEADER -->
	<div class="read_header" style="text-align:center; padding-top:20px;">
		<h1><a href="{$oDocument->getPermanentUrl()}">{$oDocument->getTitle()}</a></h1>
		<a cond="$oDocument->getHomepageUrl()" href="{$oDocument->getHomepageUrl()}" class="author">{$oDocument->getNickName()}</a>
	</div>
	<!-- /READ HEADER -->
	
	
	<div>
	<!--@if($oDocument->isExtraVarsExists() && (!$oDocument->isSecret() || $oDocument->isGranted()) )-->
	    <!--@foreach($oDocument->getExtraVars() as $key => $val)-->
	        <!--@if($val->idx==1)-->
	        {@
				$product_data = $val->getValueHTML();
	        }
	        <!--@elseif($val->name=="가격")-->
	        {@
				$product_price = $val->getValueHTML();
	        }
	        <!--@elseif($val->idx==3)-->
	        {@
				$delivery = $val->getValueHTML();
	        }
	        <!--@elseif($val->name=="내번호")-->
	        {@
				$callback = $val->getValueHTML();
	        }
	        <!--@elseif($val->name=="가게번호")-->
	        {@
				$recipient = $val->getValueHTML();
	        }
	        <!--@elseif($val->name=="상호")-->
	        {@
				$restaurant = $val->getValueHTML();
	        }
	        <!--@elseif($val->name=="상태")-->
	        {@
				$status = $val->getValueHTML();
	        }
	        <!--@elseif($val->name=="주문번호")-->
	        {@
				$order_no = $val->getValueHTML();
	        }
	        <!--@elseif($val->name=="총합")-->
	        {@
				$sum_price = $val->getValueHTML();
	        }
	        <!--@elseif($val->name=="알림")-->
	        {@
				$notification = $val->getValueHTML();
	        }
	        <!--@elseif($val->name=="배송지 주소")-->
	        {@
				$address = $val->getValueHTML();
	        }
	        <!--@elseif($val->name=="실제주문번호")-->
	        {@
				$real_no = $val->getValueHTML();
	        }
	        <!--@end-->
	    <!--@end-->
	<!--@end-->
	</div>
	
	<!-- READ BODY -->
	<div class="read_body">
		<div style="float:right; margin-right:20px;"><b>주문번호 : <font color=red>{$real_no}</font></b></div>
		
		{@
			$product_data2 = explode("&amp;&amp;", $product_data);
			$count_product = count($product_data2)-1;
			$sum_price=0;
			$tmp;
			$span = array();
			$span_tmp=1;
			$span_sum = array();
			$span_sum_tmp=0;
			$strData="";
			$strSpan="";
			$strSpan_sum="";
			
			$delivery = explode("|", $delivery);
		}
		<!--@for($i=0; $i< $count_product; $i++)-->
			{@ 
				$product[$i] = explode("|", $product_data2[$i]);
			}
		<!--@end-->
		<br />
		<!-- // 비교를 통해 같은것들끼리 묶는다 -->
		<!--@for($i=0; $i< $count_product-1; $i++)-->
			<!--@for($j=$i+1; $j< $count_product; $j++)-->
				<!--@if($product[$i][1] == $product[$j][1])-->
					{@
						$tmp = $product[$i+1];
						$product[$i+1] = $product[$j];
						$product[$j] = $tmp;
					}
				<!--@endif-->
			<!--@end-->
		<!--@end-->
		
		<!--@for($i=0; $i<$count_product;$i++)-->
			<!--@if($product[$i][1] == $product[$i+1][1])-->
				{@
					$span_tmp++;
					$span_sum_tmp += $product[$i][4];
				}
			<!--@else-->
				{@
					$span_sum_tmp += $product[$i][4];
					array_push($span_sum,$span_sum_tmp);
					array_push($span,$span_tmp);
					$span_tmp=1;
					$span_sum_tmp=0;
				}	
			<!--@endif-->
		<!--@end-->
		
		<div class="write_editor">
	    	<div class="contentView2">
	    		<table class="orderlist_1" cellspacing="0">
					<tr>
						<th style="border-bottom:2px solid #e1e1e1;">날짜</td>
						<th colspan="2" style="border-bottom:2px solid #e1e1e1;">상품</td>
						<th style="border-bottom:2px solid #e1e1e1;">가격</td>
						<th style="border-bottom:2px solid #e1e1e1;">수량</td>
						<th style="border-bottom:2px solid #e1e1e1;">총합</td>
						<th style="border-bottom:2px solid #e1e1e1; border-right:none;">배달상태</td>
					</tr>
					<tr>
						<td rowspan="{$count_product}">{date("Y-m-d")}</td>
						{@
							$row_count=0;
							$row_count2=0;
						}
						<!--@for($i=0; $i<$count_product; $i++)-->
							<!--@if($i == $row_count)-->
								<td rowspan="{$span[$row_count2]}">{$product[$i][1]}</td>
							<!--@endif-->
							
							<td>{$product[$i][2]}</td>
							<td>{$product[$i][4]/$product[$i][3]} 원</td>
							<td>{$product[$i][3]}</td>
							{@
								$sum_price += $product[$i][4];
							}
							
							<!--@if($i == $row_count)-->
								<td rowspan="{$span[$row_count2]}">{$span_sum[$row_count2]} 원</td>
								<td rowspan="{$span[$row_count2]}" style="border-right:none;">
									<deliver cond="$delivery[$i] == 1">배달준비</deliver>
									<deliver cond="$delivery[$i] == 2">배달중</deliver>
									<deliver cond="$delivery[$i] == 3">배달완료</deliver>
									<deliver cond="$delivery[$i] == 4">배달취소</deliver>
								</td>
								{@ 
									$row_count += $span[$row_count2];
									$row_count2++;
								}
							<!--@endif-->
							
							<!--@if($i+1!=$count_product)-->
								<tr>
							<!--@endif-->
						<!--@end-->
					</tr>
					<tr>
						<td colspan="3" style="border-bottom:2px solid #e1e1e1; border-top:1px solid #e1e1e1; border-right:none; background:#fcfcfc;"></td>
						<td colspan="2" style="border-bottom:2px solid #e1e1e1; border-top:1px solid #e1e1e1; background:#fcfcfc;"><b>총 결제 금액</b></td>
						<td colspan="2" style="border-bottom:2px solid #e1e1e1; border-top:1px solid #e1e1e1; border-right:none;"><a class="sum_price"></a></td>
					</tr>
				</table>
				
	    		<table class="orderlist_2" cellspacing="0">
					<tr>
						<th>내 전화번호</th>
						<td style="border-right:none;">{$oDocument->getExtraValue(4)}</td>
					</tr>
					<tr>
						<th style="border-bottom:2px solid #e1e1e1;">배송지 주소</th>
						<td style="border-right:none; border-bottom:2px solid #e1e1e1;">{$oDocument->getExtraValue(13)}</td>
					</tr>
				</table>
				
	    		<table class="orderlist_3" cellspacing="0">
					<tr>
						<th>영수증 출력하기</th>
						<td style="padding:20px; border-right:none;">
							<div id="divCart2">
								{$oDocument->getExtraValue(6)}
							</div>
							
							<div sytle="float:left; margin-top:20px; text-align:left;">
								<form>
									<input type="button" id="print" value="인쇄하기">
								</form>
							</div>
						</td>
					</tr>
					<tr>
						<th style="border-bottom:2px solid #e1e1e1;">QR CODE</th>
						<td style="padding:20px; border-right:none; border-bottom:2px solid #e1e1e1;">
							<img src="http://chart.apis.google.com/chart?chs=128x128&cht=qr&chl=http%3A%2F%2Fskku.yamnyam.com%2F%3Fdocument_srl%3D{$oDocument->document_srl}" width="128" height="128" alt="" / style="border:1px solid #e1e1e1;">
						</td>
					</tr>
				</table>

			</div>
			
			<script type="text/javascript">
				(function($){
				    $(function(){
						$('.sum_price').append('<b>{$sum_price} 원</b>');
						$('.contentvar').val($('.contentView2').html());
				    });
				    $('#print').click(function(){
				    	$('#divCart2').printElement({printMode:'popup', leaveOpen:true});
				    });
				})(jQuery);
			</script>
		</div>
	</div>
	
	<div class="map_body">
		<div id="map_canvas"></div>		
	</div>
	<!-- /READ BODY -->
	
	<!-- READ FOOTER -->
	<div class="read_footer">
		<div cond="$oDocument->hasUploadedFiles()" class="fileList">
			<button type="button" class="toggleFile" onclick="jQuery(this).next('ul.files').toggle();">{$lang->uploaded_file} ({$oDocument->get('uploaded_count')})</button>
			<ul class="files">
				<li loop="$oDocument->getUploadedFiles()=>$key,$file"><a href="{getUrl('')}{$file->download_url}">{$file->source_filename} <span class="fileSize">[File Size:{FileHandler::filesize($file->file_size)}/Download:{number_format($file->download_count)}]</span></a></li>
			</ul>
		</div>
	</div>
	<!-- /READ FOOTER -->
</div>
